package com.example.game_logic;

import java.util.Vector;

import com.example.game_logic.Color.ColorID;



public class Line {
	
	protected Bloc startBloc_;
	
	protected Vector<Bloc> blocsExtremity_;
	
	protected Color color_;
	
	public Line(Color color)
	{
		startBloc_ = null;
		color_ = color;
		blocsExtremity_ = new Vector<Bloc>();
	}
	
	public boolean isLineComplete()
	{
		for (Bloc bloc : blocsExtremity_)
		{
			if (!bloc.isUsed())
			{
				return false;
			}
		}
		return true;
	}
	
	public boolean addExtremityBloc(Bloc bloc)
	{
		if ( blocsExtremity_.size() >= 2)
		{
			return false;
		}
		
		bloc.setLine(this);
		blocsExtremity_.add(bloc);
		
		return true;
	}
	
	public void setStartBloc(Bloc bloc)
	{
		if (startBloc_ != null)
		{
			startBloc_.setUnused();
			startBloc_ = null;
		}
		startBloc_ = bloc;
		startBloc_.setParent(null);
	}
	
	public Bloc getStartBloc()
	{
		return startBloc_;
	}
	
	public ColorID getColor()
	{
		return color_.getID();
	}
}
